﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Roton2.MemoryEmulation
{
    /// <summary>
    /// Representation of a linear memory block.
    /// </summary>
    public class Block
    {
        private byte[] memory;
        private int offset;

        /// <summary>
        /// Allocate a block of memory with the specified number of bytes and offset.
        /// </summary>
        public Block(int size, int offset)
        {
            this.memory = new byte[size];
            this.offset = offset;
        }

        /// <summary>
        /// Get or set a byte in the memory block.
        /// </summary>
        public byte this[int offset]
        {
            get
            {
                return memory[offset - this.offset];
            }
            set
            {
                memory[offset - this.offset] = value;
            }
        }
    }
}
